<?php
/**
 *手机支付宝支付
 * User: 梁晓伟  lxw11109@gmail.com
 * Date: 2017-09-12
 * Time: 17:27
 */

namespace App\Libs\Contracts\PayMent\AliPay;

use App\Libs\Contracts\PayMent\AliPay\Web\pagepay\buildermodel\AlipayTradeRefundContentBuilder;
use App\Libs\Contracts\PayMent\AliPay\Web\pagepay\service\AlipayTradeService;

class AliApp
{
    public function pay($order)
    {
        require_once '/service/wxapp/kangtaiCloud/server/app/Libs/Contracts/PayMent/AliPay/App/aop/AopClient.php';
      //  require_once '/service/wxapp/kangtaiCloud/server/app/Libs/Contracts/PayMent/AliPay/App/aop/request/AlipayTradeAppPayRequest.php';
        $aop = new AopClient();
        dd(11);
        $aop->gatewayUrl = "https://openapi.alipay.com/gateway.do";
        $aop->appId = "2021001164699261";
        $aop->rsaPrivateKey = 'MIIEogIBAAKCAQEAo1iTlshGRrojjFCZUQRVetdkwCDvgIsFvmaBzZkXzwEVuC3iTfiQBxrDLV39D6Q1gPSgVJxi9PgobQdSHq6fonf2hC0k5txFqx8vyBqpL+MJ7HG77SIkjudqlQkpUfdrH4ifBfndp91q+R6NMF09M3UYvEusSOZgHJDVKeRB0fIn2K83kQgMgh9pmtVDWwkl7Y6RnE1awtQ9yT9d2ZJDHssXJHWRvfNsY9dW2iwy4etJDTewXaDuoxN5CJNcShBBN10rboDQf0h5R7ncvRE5umIzYv8Tr7/xzB3ZqnCzmNNQQOi2vHDbfusri7vrPCFEV4TS8ncJe4vq4ec+dpcsvwIDAQABAoIBAF1+7bt4lwEUuhQubhM5b9QIRdrS/0OMT5VUBygvYLlT3aK2YLpQc+AdKWpmSdsSGq3dV4gWm22sPTdq4U4+lZDhKXEuhdi+bAIur6LR39VRFvUHhJGO4W4Kd68mt0f7Xo2GHb/F7WGQExLUsevk8orpk2bzyYFQm+K948U+qY4JKUjrgDR15a7JpKRPVPZVcjhrfH4k5L31gN8EHj9R+RuUcYhtKS5B0bp/5hrTlV3K+EbvLVah4nX4g4z1okhzYx/HD30/n/Wliizhqgvm7/MiXttRsZ+auMXF6nUy2NfylKdLG6iZeIpkgBcJCWmPOoTZMA2+jsRSsP98+zxmwkECgYEA6KsFN+YnBTKsLnSvp6D7C7+eTEyyUckNxNrKKPBY0bXE2C9SimBVRUN52j/FiT71o4EKR/gljkNDHUoEmKz41WbmSHiI9djWsU+XZab3EzcbyPWaZ/1mIeyvF+sEY3MAaUecme0Vq3oZnb3jVyJnLR9Q8emENooUe0dJvipGofMCgYEAs7nxWQqLPmuSU8kkne0x6dJzmEkZZ6AdEcTgV6pGGzhXcx4zq2cmzm7q4sm5X8JLl/6rKuG/V0H7+Few5EZovp1ZBxLo9+6jIxLATyOGqSWEpDScGzon2q3sU2NkkuZAOfJdgitQsof6X+tf6ynGEu7o4q4cSTuZB9thNXAPsQUCgYAwh+uwuzsMZINxtTkmd/elfbShKaZQVOWgWBqu62M7avTCOyy2XF2s8uQp1/92H0HRdwsT8/ixceo/476Nsha9PJdwKmQ3E6HEnltwAqGqymXrRv+MDVkOXnYvQQBLViOR0jQiD0fj2rYZJxCSjkSDLvMNYq4HSkn3ZOlG1z6gbQKBgE++xnbitcv5gRDKJAQq1cXRCldcv/f51EwpFf3v4HF9e1fp47U+7LoV/wSnyyfRFyeW6S36wqKd9YZIqoVvNFS3jmQUIOi5qwsJ6+hxc/OjYQpXCZkPIdXm7ABIDr0biw3rG1CBlanRqedbkdDPVULbXNwPsx9PYWRaE/TZBy1dAoGAYeK42wUMsr7cfX0MNJEchxbXhML7MTIUa9KJlZ6aY5A3DGGa8GK9KNXHDPt9Ke8vH0xOcm2sa0qfv0zqYXbTCROPrpgB4QeEIKj0rsNF6DtjbfsZfGEzkDZntZoMar2t0V/9zkZViae7NGPkkqsfUtUw5Y0yLvppoSP1WPGUW+s=';
        $aop->format = "json";
        $aop->charset = "UTF-8";
        $aop->signType = "RSA2";
        $aop->alipayrsaPublicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQzifJVfqM/axSRFvSAVFXGKWwysiG6NWbCv3qrrEXNceW9drKmjnwGKo3mpAP2XRqzHnjPlHJTSspw6HWLpqpwv3I0+jVgtz8XMWl1Rviyhv+fObGb0FP8eI5VZm3sDbpMy0UplbbWn9kwk6QfZZolZXG9yvar5YTPFRcNHdiVRV9Ea5Ph9QN51F1gahRhSp1d0FfnXvkmBJ5ops5FNlTcjyRJh50vUTvhssm5D5Z5iD8lquG9e9K7KeMum4TUyMNLX0/QEQkt4Ir2L+5WzHnS12P15E+og3zGrXVLr8enUFFIr9FDSBtMKIqQjgggQm7V0rEwY4BbzzIZydzZNzwIDAQAB';
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称：alipay.trade.app.pay
        $request = new AlipayTradeAppPayRequest();
//SDK已经封装掉了公共参数，这里只需要传入业务参数
        $bizcontent = "{\"body\":\"我是测试数据\","
            . "\"subject\": \"App支付测试\","
            . "\"out_trade_no\": \"20170125test01\","
            . "\"timeout_express\": \"30m\","
            . "\"total_amount\": \"0.01\","
            . "\"product_code\":\"QUICK_MSECURITY_PAY\""
            . "}";
        $request->setNotifyUrl(env("ALI_NOTIFY_URL"));
        $request->setBizContent($bizcontent);
//这里和普通的接口调用不同，使用的是sdkExecute
        $response = $aop->sdkExecute($request);
        dd($response);
//htmlspecialchars是为了输出到页面时防止被浏览器将关键参数html转义，实际打印到日志以及http传输不会有这个问题
        echo htmlspecialchars($response);//就是orderString 可以直接给客户端请求，无需再做处理。
    }


}